﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ajayumi.Platform.WinForm.WorkSpace;
using ajayumi.Test.WinForm.Dexpress.Forms;
using System.Windows.Forms;

namespace ajayumi.Test.WinForm.Dexpress.AppModules
{
    internal class Test1WorkSpace : WorkSpaceBase
    {

        public Test1WorkSpace()
            : base("Test1", false)
        {
            this.Description = "我是用于测试的工作空间";
        }



        public override System.Windows.Forms.ToolStripItem[] InitToolStripItems
        {
            get
            {
                this.RegisterAction();

                IParentToolStripButtons pToolStripButtons = (IParentToolStripButtons)this.ParentContainer;

                return new ToolStripButton[] { 
                    pToolStripButtons.AddBtn,
                    pToolStripButtons.ExitBtn 
                };
            }
        }

        protected override System.Windows.Forms.ContainerControl InitContainerCtrl()
        {
            FrmTest1 frm = new FrmTest1();
            return frm;
        }

        public override void RegisterAction()
        {
            this.UnRegisterAction();

            IParentToolStripButtons pToolStripButtons = (IParentToolStripButtons)this.ParentContainer;
            pToolStripButtons.AddBtn.Click += AddBtn_Click;
        }

        public override void UnRegisterAction()
        {
            IParentToolStripButtons pToolStripButtons = (IParentToolStripButtons)this.ParentContainer;
            pToolStripButtons.AddBtn.Click -= AddBtn_Click;
        }

        void AddBtn_Click(object sender, EventArgs e)
        {
            DevExpress.XtraEditors.XtraMessageBox.Show(
                string.Format("{0} 点击添加按钮", this.Name),
                "提示",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);
        }

    }
}
